const common = require("../../../common/common")
const AJAX = require("../../../common/request")
const API = require("../../../common/api")
const App = getApp()
Page({
    data: {
        navTop: 0,
        navContentHeight: 0,
        placeholderHeight: 0,
        scrollHeight: 0,
        adHeight: 0,
        tabId: 1,
        listbSkin: [],
        UPLOADURL: "",
        height: 0,
    },
    async onLoad(options) {
        this.setData({
            navTop: App.globalData.navTop,
            navContentHeight: App.globalData.navContentHeight,
            UPLOADURL: API.UPLOADURL,
            height: App.globalData.windowHeight
        })
        const query = wx.createSelectorQuery();
        query.select('.head').boundingClientRect();
        await query.exec((res) => {
            console.log(res)
            this.setData({
                placeholderHeight: res[0].height,
                scrollHeight: App.globalData.windowHeight - this.data.navTop - this.data.adHeight - res[0].height - 10
            })
        });
        AJAX.POST("/system/AppWechat/listbSkin", {}).then((res) => {
            let data = res.rows
            data.forEach((item, i) => {
                item.childen.forEach((ch, j) => {
                    //脓疱疮 
                    if (ch.id == 215) {
                        data[i].childen[j].top = 12
                        data[i].childen[j].left = 10
                        data[i].childen[j].right = null
                        data[i].childen[j].height = 50
                        data[i].childen[j].lineWidth = 200
                        data[i].childen[j].transform = "rotate(13deg)"
                        data[i].childen[j].transformOrigin = "0 100%"
                    }
                    //单纯疱疹
                    if (ch.id == 216) {
                        data[i].childen[j].top = 12
                        data[i].childen[j].left = null
                        data[i].childen[j].right = 10
                        data[i].childen[j].height = 60
                        data[i].childen[j].lineWidth = 200
                        data[i].childen[j].transform = "rotate(-13deg)"
                        data[i].childen[j].transformOrigin = "100% 0"
                    }
                    //过敏性皮炎
                    if (ch.id == 205) {
                        data[i].childen[j].top = 21
                        data[i].childen[j].left = 10
                        data[i].childen[j].right = null
                        data[i].childen[j].height = 75
                        data[i].childen[j].lineWidth = 130
                        data[i].childen[j].transform = "rotate(30deg)"
                        data[i].childen[j].transformOrigin = "0 100%"
                    }
                    //脂溢性皮炎
                    if (ch.id == 206) {
                        data[i].childen[j].top = 21
                        data[i].childen[j].left = null
                        data[i].childen[j].right = 10
                        data[i].childen[j].height = 75
                        data[i].childen[j].lineWidth = 130
                        data[i].childen[j].transform = "rotate(-30deg)"
                        data[i].childen[j].transformOrigin = "100% 0"
                    }
                    //神经性皮炎
                    if (ch.id == 207) {
                        data[i].childen[j].top = 30
                        data[i].childen[j].left = 10
                        data[i].childen[j].right = null
                        data[i].childen[j].height = 75
                        data[i].childen[j].lineWidth = 60
                        data[i].childen[j].transform = "rotate(30deg)"
                        data[i].childen[j].transformOrigin = "0 100%"
                    }
                    //荨麻疹
                    if (ch.id == 208) {
                        data[i].childen[j].top = 30
                        data[i].childen[j].left = null
                        data[i].childen[j].right = 10
                        data[i].childen[j].height = 42
                        data[i].childen[j].lineWidth = 120
                        data[i].childen[j].transform = "rotate(-10deg)"
                        data[i].childen[j].transformOrigin = "100% 0"
                    }
                    //体股藓
                    if (ch.id == 210) {
                        data[i].childen[j].top = 40
                        data[i].childen[j].left = 10
                        data[i].childen[j].right = null
                        data[i].childen[j].height = 50
                        data[i].childen[j].lineWidth = 170
                        data[i].childen[j].transform = "rotate(-15deg)"
                        data[i].childen[j].transformOrigin = "0 100%"
                    }
                    //花斑癣
                    if (ch.id == 212) {
                        data[i].childen[j].top = 40
                        data[i].childen[j].left = null
                        data[i].childen[j].right = 10
                        data[i].childen[j].height = 42
                        data[i].childen[j].lineWidth = 200
                        data[i].childen[j].transform = "rotate(28deg)"
                        data[i].childen[j].transformOrigin = "100% 0"
                    }
                    //疖
                    if (ch.id == 214) {
                        data[i].childen[j].top = 48
                        data[i].childen[j].left = 10
                        data[i].childen[j].right = null
                        data[i].childen[j].height = 20
                        data[i].childen[j].lineWidth = 200
                        data[i].childen[j].transform = "rotate(-15deg)"
                        data[i].childen[j].transformOrigin = "0 100%"
                    }
                    //带状疱疹
                    if (ch.id == 217) {
                        data[i].childen[j].top = 48
                        data[i].childen[j].left = null
                        data[i].childen[j].right = 10
                        data[i].childen[j].height = 58
                        data[i].childen[j].lineWidth = 150
                        data[i].childen[j].transform = "rotate(30deg)"
                        data[i].childen[j].transformOrigin = "100% 0"
                    }
                    //湿疹
                    if (ch.id == 204) {
                        data[i].childen[j].top = 50
                        data[i].childen[j].left = 10
                        data[i].childen[j].right = null
                        data[i].childen[j].height = 35
                        data[i].childen[j].lineWidth = 200
                        data[i].childen[j].transform = "rotate(-20deg)"
                        data[i].childen[j].transformOrigin = "0 100%"
                    }
                    //手足癣
                    if (ch.id == 209) {
                        data[i].childen[j].top = 35
                        data[i].childen[j].left = null
                        data[i].childen[j].right = 10
                        data[i].childen[j].height = 40
                        data[i].childen[j].lineWidth = 200
                        data[i].childen[j].transform = "rotate(-20deg)"
                        data[i].childen[j].transformOrigin = "100% 0"
                    }
                    //灰指甲
                    if (ch.id == 211) {
                        data[i].childen[j].top = 85
                        data[i].childen[j].left = null
                        data[i].childen[j].right = 10
                        data[i].childen[j].height = 40
                        data[i].childen[j].lineWidth = 200
                        data[i].childen[j].transform = "rotate(20deg)"
                        data[i].childen[j].transformOrigin = "100% 0"
                    }
                    //毛囊炎
                    if (ch.id == 213) {
                        data[i].childen[j].top = 12
                        data[i].childen[j].left = 10
                        data[i].childen[j].right = null
                        data[i].childen[j].height = 50
                        data[i].childen[j].lineWidth = 200
                        data[i].childen[j].transform = "rotate(13deg)"
                        data[i].childen[j].transformOrigin = "0 100%"
                    }
                })
            })
            if (res.code == 200) {
                this.setData({
                    listbSkin: data
                })
            }


        })
    },
    setTab(e) {
        console.log(e.currentTarget.dataset.index)
        this.setData({
            tabId: e.currentTarget.dataset.index
        })
    },
    goBack() {
        const pages = getCurrentPages();
        //获取不到上级返回首页
        if (pages.length > 1) {
            wx.navigateBack({})
        } else {
            wx.reLaunch({
                url: '/pages/index/index',
            })
        }
    },
    view(e) {

        wx.navigateTo({
            url: '/pages/index/baike/detail/index?id=' + e.currentTarget.dataset.id,
        })
    },
    onShareAppMessage(options) {
        // 默认分享配置
        return {
            title: App.globalData.onShareAppMessage.title,
            path: App.globalData.onShareAppMessage.path,
            imageUrl: App.globalData.onShareAppMessage.imageUrl,
        }
    },
});